package com.gatico;

import io.netty.channel.ChannelHandlerContext;

import java.net.Socket;

public class ProxyClient {
    Socket socket;
    ChannelHandlerContext server;

    public ProxyClient(Socket socket, ChannelHandlerContext server) {
        this.socket = socket;
        this.server = server;
    }

//    public void start() {
//        byte[] arr = new byte[1024];
//        int len;
//        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//        try {
//            while ((len = IOUtils.read(socket.getInputStream(), arr)) > 0) {
//                byteArrayOutputStream.write(arr, 0, len);
//            }
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        }
//        ProxyProtocol protocol = new ProxyProtocol();
//        protocol.type = ProxyProtocol.TYPE.HTTP.value();
//        InetSocketAddress address = (InetSocketAddress) socket.getRemoteSocketAddress();
//        protocol.ip = IPv4Utils.strToint(address.getAddress().getHostAddress());
//        protocol.port = address.getPort();
//        protocol.length = byteArrayOutputStream.size();
//        protocol.data = byteArrayOutputStream.toByteArray();
//        server.writeAndFlush(protocol);
//    }
}
